import request from "@/utils/request";

export const customerRegisterService = (registerData) => {
    return request.post('/customer/register', registerData)
}

export const customerLoginService = (loginData) => {
    const params = new URLSearchParams();
    for(let key in loginData) {
        params.append(key, loginData[key]);
    }
    return request.post('/customer/login', params)
}

export const userInfoService = () => {
    return request.get('/customer/userInfo')
}

export const customerRepasswordService = (password) => {
    return request.patch('/customer/updatePwd', password)
}

export const customerAvatarUpdateService = (avatarUrl) => {
    return request.patch('/customer/updateAvatar', avatarUrl)
}

export const customerInfoUpdateService = (userInfo) => {
    return request.put('/customer/update', userInfo)
}

export const putOrderService = (form, book) => {
    return request.put('/customer/order', {data: form, book})
}

export const getOrderService = () => {
    return request.get('/customer/listorder')
}

export const addCommentService = (commentModel) => {
    return request.put('/customer/addComment', commentModel)
}